using System.Collections.Generic;
using UnityEditor.ShaderGraph.Drawing.Inspector.PropertyDrawers;
using UnityEngine;

public class ButtonGroupBase : MonoBehaviour
{
    List<BlockButton> m_ButtonList = new List<BlockButton>();
    // Start is called once before the first execution of Update after the MonoBehaviour is created
    void Start()
    {
        
    }

    protected void AddButton( BlockButton button)
    {
        m_ButtonList.Add(button);
    }

    protected void FreshButton()
    {
        for (int i = 0; i < m_ButtonList.Count; ++i)
        {
            m_ButtonList[i].DoInit(i, OnClick);
        }
    }
    protected virtual void OnClickButton(int index)
    {

    }
    void OnClick(int index)
    {
        for (int i = 0; i < m_ButtonList.Count; ++i)
        {
            m_ButtonList[i].SetSelected(i == index);
        }
        OnClickButton(index);
    }
    
}
